<template>
  <div>
    <vol-box
      :lazy="true"
      :model.sync="model.box2"
      title="下单"
      :height="600"
      :width="900"
      :padding="15"
    >
      <VolForm
        ref="myformadd"
        :loadKey="loadKey"
        :formFileds="formFileds"
        :formRules="formRules"
      >
      </VolForm>
      <div slot="footer">
        <Button type="success" @click="getForm">保存</Button>
        <Button type="error" @click="reset">重置</Button>

        <Button type="info" @click="model.box2 = false">
          <Icon type="md-close" />关闭
        </Button>
      </div>
      <Tabs>
        <TabPane label="商品明细" icon="ios-aperture">
          <div class="tabs1-header">
            <div class="message"></div>
          </div>
          <vol-table
            ref="tables"
            :clickEdit="true"
            :loadKey="true"
            :columns="tableColumns1"
            :pagination-hide="false"
            :height="200"
            :tableData="tableData"
            url=""
            :index="true"
            @rowClick="rowClick"
          ></vol-table>
        </TabPane>
      </Tabs>
      <choosereservation
        ref="choosereservation"
        style="margin-bottom: 20px"
      ></choosereservation>
      <choosegoods ref="choosegoods"></choosegoods>
    </vol-box>

    <vol-box
      :lazy="true"
      :model.sync="model.box3"
      title="手工录入单"
      :height="550"
      :width="1000"
      :padding="15"
    >
      <VolForm
        :loadKey="true"
        ref="formFieldsreset"
        :formFields="formFields1"
        :formRules="formRules1"
      ></VolForm>
      <vol-box
        :lazy="true"
        :model.sync="model.box4"
        title="选择产品"
        :height="500"
        :width="900"
        :padding="15"
      >
        <VolForm
          ref="myform"
          :loadKey="loadKey"
          :formFileds="formFileds3"
          :formRules="formRules3"
          v-if="productType == '1'"
        ></VolForm>
        <VolForm
          ref="myform"
          :loadKey="loadKey"
          :formFileds="formFileds4"
          :formRules="formRules4"
          v-else-if="productType == '2'"
        ></VolForm>
        <VolForm
          ref="myform"
          :loadKey="loadKey"
          :formFileds="formFileds5"
          :formRules="formRules7"
          v-else-if="productType == '3'"
        ></VolForm>
        <VolForm
          ref="myform"
          :loadKey="loadKey"
          :formFileds="formly"
          :formRules="formRulesly"
          v-show="flxjxzly"
        ></VolForm>

        <div class="hx">
          选择产品&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <el-radio-group v-model="productType" @change="selectProduct">
            <el-radio label="1">产品</el-radio>
            <!-- <el-radio label="2">酒店</el-radio> -->
            <!-- 不支持款待 -->
            <!-- <el-radio v-if="formFields1.reservationType != 4" label="3"
              >冬/夏令营</el-radio -->
            >
          </el-radio-group>
        </div>
        <div class="cascader" v-if="productType == '1'">
          <div class="casd">
            <el-cascader
              ref="cascder"
              v-model="cascaderValue"
              :options="treeProtyLIST"
              clearable
              :props="{
                value: 'id',
                label: 'typeName',
                children: 'children',
                checkStrictly: true
              }"
              @change="changeCasc"
            ></el-cascader>
          </div>
          <div class="edit_dev">
            <el-transfer
              filterable
              v-model="selectValue"
              :data="productsList"
              :titles="titles"
              :right-default-checked="selectValue"
              :render-content="renderFuncName"
            ></el-transfer>
          </div>
        </div>
        <div class="cascader" v-if="productType == '2'">
          <div class="edit_dev">
            <el-transfer
              filterable
              v-model="selectValue"
              :data="GoodsHotelList"
              :titles="titles"
              :right-default-checked="selectValue"
              :render-content="renderFunc"
            ></el-transfer>
          </div>
        </div>
        <div class="cascader" v-if="productType == '3'">
          <div class="casd">
            <el-cascader
              ref="cascder"
              v-model="cascaderValue"
              :options="treeProtyLISTS"
              clearable
              :props="{
                value: 'productid',
                label: 'productName',
                children: 'children',
                checkStrictly: true
              }"
              @change="campChange"
            ></el-cascader>
          </div>
          <div class="edit_dev">
            <el-transfer
              filterable
              v-model="selectValue"
              :data="campList"
              :titles="titles"
              :right-default-checked="selectValue"
            ></el-transfer>
          </div>
        </div>
        <div slot="footer">
          <Button type="default" @click="closeChild">确认</Button>
        </div>
      </vol-box>
      <div class="hx">
        商品结算
        <Button type="info" size="small" ghost @click="open3()">
          选择产品
        </Button>
      </div>
      <el-table
        class="table"
        ref="goodsTableref"
        :data="goodTableData"
        tooltip-effect="dark"
        height="250"
        style="width: 100%"
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" min-width="8.5%"> </el-table-column>
        <el-table-column
          prop="title"
          label="商品信息"
          min-width="20%"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column label="单价" min-width="8%">
          <template slot-scope="scope">
            <div v-if="productType == '1'">
              {{ scope.row.secondprice.toFixed(2) }}
            </div>
            <div v-else-if="productType == '2'">
              {{ scope.row.minprice.toFixed(2) }}
            </div>
            <div v-else-if="productType == '3'">{{ scope.row.priceCamp }}</div>
          </template>
        </el-table-column>
        <el-table-column
          prop="playStartDate"
          label="游玩日期"
          min-width="10%"
          v-if="productType == '1'"
        >
        </el-table-column>
        <el-table-column
          prop="playStartDate"
          label="入住时间"
          min-width="10%"
          v-if="productType == '2'"
        >
        </el-table-column>
        <el-table-column label=" 数量" min-width="13%">
          <template slot-scope="scope">
            <el-input-number
              v-if="productType == '1'"
              ref="refNumber"
              size="mini"
              :min="0"
              v-model="scope.row.num"
              @change="selectasghdjks"
            ></el-input-number>
            <div v-else-if="productType == '2'"></div>
            <div v-else-if="productType == '3'">1</div>
          </template>
        </el-table-column>
        <el-table-column
          label="使用人数"
          min-width="11%"
          v-if="productType == '3'"
        >
          <template slot-scope="scope">
            {{ scope.row.people_num }}
          </template>
        </el-table-column>
        <el-table-column label="总金额" min-width="11%">
          <template slot-scope="scope">
            <div v-if="productType == '1' || productType == '2'">
              {{ (scope.row.secondprice * scope.row.num).toFixed(2) }}
            </div>
            <div v-else-if="productType == '3'">
              {{ (scope.row.priceCamp * scope.row.num).toFixed(2) }}
            </div>
          </template>
        </el-table-column>
        <el-table-column label="使用人" min-width="11%" prop="useRen">
        </el-table-column>
        <el-table-column label="操作" min-width="15%">
          <template slot-scope="scope">
            <el-button
              v-if="
                editFormFields.teamScheduled == 0 ||
                  (editFormFields.teamScheduled == 1 &&
                    editFormFields.teamType == 1)
              "
              type="text"
              size="small"
              icon="el-icon-edit"
              @click="userButton(scope.row, 0, 1)"
            >
              使用人
            </el-button>
            <el-button
              type="text"
              size="small"
              class="deleteBtn"
              icon="el-icon-delete"
              @click="delgood(scope.row.id)"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <div style="float: right; font-size: 14px; margin-left: 20px">
        商品金额合计:{{ changeNum2.toFixed(2) }}元
      </div>
      <div style="float: right; font-size: 14px; margin-left: 20px">
        商品折后金额:{{
          changeZH == "1" ? changeNum2.toFixed(2) : changeTotalNum.toFixed(2)
        }}元
      </div>
      <div
        v-if="
          this.formFields1.teamScheduled == 1 && this.formFields1.teamType == 1
        "
      >
        <div class="hx">
          人员信息新增
        </div>
        <VolForm
          ref="myform"
          :label-width="100"
          :loadKey="true"
          :formFields="formFields2"
          :formRules="formRules2"
        ></VolForm>
        <div style="text-align: right">
          <Button type="default" @click="researcherCom">人员添加</Button>
          <Button type="info" size="small" ghost @click="downloadExcel"
            >下载Excel模板</Button
          >
          <div style="float: right">
            <VolUpload :url="url" :upload-after="uploadAfter"> </VolUpload>
          </div>
        </div>
        <el-table
          ref="multipleTable"
          :data="researchersInfo"
          tooltip-effect="dark"
          style="width: 100%"
          height="250"
        >
          <el-table-column type="selection" width="55"> </el-table-column>
          <el-table-column prop="name" label="姓名" width="120">
          </el-table-column>
          <el-table-column prop="phone" label="手机号" width="120">
          </el-table-column>
          <el-table-column prop="id_card" label="证件号" show-overflow-tooltip>
          </el-table-column>
          <el-table-column label="操作" min-width="15%">
            <template slot-scope="scope">
              <el-button
                type="text"
                size="small"
                class="deleteBtn"
                icon="el-icon-delete"
                @click="deluser(scope.row.phone)"
                >删除</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </div>

      <div class="hx" v-if="this.couponList">
        优惠券查询
        <Button
          type="info"
          size="small"
          ghost
          @click="open5()"
          v-if="this.couponList"
        >
          查询优惠券
        </Button>
      </div>
      <vol-table
        ref="CouponMemberTable"
        :columns="CouponMemberid"
        :height="200"
        v-show="this.couponList"
        :tableData="CouponMemberidData"
        :index="false"
        :single="true"
        @rowChange="getSelecte()"
      >
      </vol-table>
      <div slot="footer">
        <Button
          type="default"
          v-if="productType == '3'"
          :loading="loading"
          @click="campsubmit('editFormFields')"
          >确认</Button
        >

        <Button
          type="default"
          v-else
          :loading="loading"
          @click="submit('editFormFields')"
          >确认</Button
        >
        <Button type="default" @click="model.box3 = false">关闭</Button>
      </div>
    </vol-box>
    <vol-box
      :lazy="true"
      :model.sync="model.box6"
      title="添加使用人"
      :height="300"
      :width="900"
      :padding="15"
    >
      <div class="hx">人员信息新增</div>
      <VolForm
        ref="myform"
        :label-width="100"
        :loadKey="true"
        :formFields="formFields2"
        :formRules="formRules2"
      ></VolForm>
      <div style="text-align: right">
        <Button type="default" @click="researcherCom">人员添加</Button>
        <Button type="info" size="small" ghost @click="downloadExcel"
          >下载Excel模板</Button
        >
        <div style="float: right">
          <VolUploadFile :url="url" :upload-after="uploadAfter"></VolUploadFile>
        </div>
      </div>
      <el-table
        ref="researchersInfoTable"
        :data="researchersInfo"
        tooltip-effect="dark"
        style="width: 100%"
        @selection-change="handleSelection"
      >
        <el-table-column type="selection" width="55"> </el-table-column>
        <el-table-column prop="name" label="姓名" width="120">
        </el-table-column>
        <el-table-column prop="phone" label="手机号" width="120">
        </el-table-column>
        <el-table-column prop="id_card" label="证件号" show-overflow-tooltip>
        </el-table-column>
        <el-table-column label="操作" min-width="15%">
          <template slot-scope="scope">
            <el-button
              type="text"
              size="small"
              class="deleteBtn"
              icon="el-icon-delete"
              @click="deluser(scope.row.phone)"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <div slot="footer">
        <Button type="default" @click="closebox6">确认</Button>
      </div>
    </vol-box>
    <vol-box
      :lazy="true"
      :model.sync="model.box12"
      title="添加使用人"
      :height="600"
      :width="900"
      :padding="15"
    >
      <div class="hx">人员信息新增</div>
      <VolForm
        ref="myformuser"
        :label-width="100"
        :loadKey="true"
        :formFields="formFields12"
        :formRules="formRules12"
      ></VolForm>
      <div style="text-align: right">
        <Button type="default" @click="campAdd">人员添加</Button>
      </div>
      <el-table
        ref="researchersInfoTable"
        :data="researchersInfo"
        tooltip-effect="dark"
        style="width: 100%"
        @selection-change="handleSelection"
      >
        <el-table-column type="selection" width="55"> </el-table-column>
        <el-table-column prop="name" label="姓名" width="120">
        </el-table-column>
        <el-table-column prop="phone" label="手机号" width="120">
        </el-table-column>
        <el-table-column prop="id_card" label="证件号" show-overflow-tooltip>
        </el-table-column>
        <el-table-column label="操作" min-width="15%">
          <template slot-scope="scope">
            <el-button
              type="text"
              size="small"
              class="deleteBtn"
              icon="el-icon-delete"
              @click="deluser(scope.row.phone)"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <div slot="footer">
        <Button type="default" @click="closebox7">确认</Button>
      </div>
    </vol-box>
  </div>
</template>
<script>
import VolHeader from "@/components/basic/VolHeader.vue";
import VolForm from "@/components/basic/VolForm.vue";
import VolBox from "@/components/basic/VolBox.vue";
import VolUploadFile from "@/components/basic/VolUploadFile.vue";
import VolTable from "@/components/basic/VolTable.vue";
import choosereservation from "../../mall/volumn/ChooseReservation.vue";
import choosegoods from "./ChooseGoods";
import V_RecordManually from "../../../views/order/V_RecordManually.vue";
import dateFunc from "../../../assets/vue-fullcalendar/components/dateFunc";

export default {
  components: {
    VolForm,
    VolUploadFile,
    VolBox,
    VolTable,
    choosereservation,
    choosegoods,
    V_RecordManually,
    VolHeader
  },
  watch: {
    "formFields1.bookingName"(n, o) {
      if (this.changeAll == "1") {
        this.goodTableData.forEach(res => {
          res.useRen = n;
        });
      }
    },
    formFileds4: {
      handler(n, o) {
        if (
          this.formFileds4.hotelid !== "" &&
          this.formFileds4.roomcode !== "" &&
          this.formFileds4.distributionid !== "" &&
          this.formFileds4.date !== "" &&
          this.formFileds4.stockNumebr !== ""
        ) {
          let formFileds4 = {
            hotelid: this.formFileds4.hotelid,
            roomcode: this.formFileds4.roomcode,
            distributionid: this.formFileds4.distributionid,
            stockNumebr: this.formFileds4.stockNumebr,
            phone: this.formFields1.bookingPhone,
            startDate: this.formFileds4.date[0],
            endDate: this.formFileds4.date[1]
          };
          this.http
            .post("api/Mall_good/GetMallGoodsHotel", formFileds4)
            .then(res => {
              this.GoodsHotelList = [];
              let arr = [];
              if (res.data.length != 0) {
                res.data.forEach(i => {
                  let obj = {
                    label: i.name,
                    value: i.goods_id,
                    key: i.goods_id,
                    ...i
                  };
                  arr.push(obj);
                });
                this.GoodsHotelList.push(...arr);
              }
            });
        }
      },
      deep: true
    },
    checkrows: {
      handler(n, o) {
        if (n.length == 0) {
          this.changeZH = "1";
          this.changeTotalNum = this.changeNum2;
        }
      },
      deep: true,
      immediate: true
    },
    formFileds3: {
      handler(n, o) {
        if (
          this.formFileds3.distributorCode !== "" &&
          this.formFileds3.date !== ""
        )
          this.http
            .get(
              "api/producttypes/GetDistriProductType?distributorCode=" +
                this.formFileds3.distributorCode
            )
            .then(res => {
              let newarr = res.data.filter(function(item, index, arr0) {
                return item.typeName != "酒店";
              });
              this.treeProtyLIST = newarr;
            });
        this.productType = "1";
      },
      deep: true,
      immediate: true
    },
    formFileds5: {
      handler(n, o) {
        if (this.formFileds5.distributorCode !== "") this.productType = "3";
      },
      deep: true,
      immediate: true
    }
  },
  created() {
    let reserveValue = this.getOption("reserveValue");
    let param = {
      accName: "",
      accCode: "",
      customer: "",
      phone: "",
      isvalid: null,
      start: 0,
      count: 1000,
      Credit: 1
    };
    this.http.post("/api/AccountsMain/AccountsGet", param).then(res => {
      let list = [];
      res.data.accounts.forEach(o => {
        let obj = {
          value: o.accMain.account_name,
          key: o.accMain.account_code_fk
        };
        list.push(obj);
        this.$set(reserveValue, "data", list);
      });
    });
    let distributorCode = this.getOption3("distributorCode");
    let distributionid = this.getOption4("distributionid");
    let hotelid = this.getOption4("hotelid");
    // manudistributorList 把渠道的分销商过滤掉
    this.http
      .post("/api/Dictionary/GetVueDictionary", ["manudistributorList"])
      .then(res => {
        this.distributorList = [];
        res.forEach(o => {
          if (o.dicNo == "manudistributorList") {
            o.data.forEach(i => {
              let obj = {
                value: i.value,
                key: i.key
              };
              this.distributorList.push(obj);
              this.$set(distributorCode, "data", this.distributorList);
              this.$set(distributionid, "data", this.distributorList);
            });
          }
        });
      });
    // 获取下拉酒店名称
    let param1 = {
      page: 1,
      rows: 1000,
      sort: "id",
      order: "desc",
      wheres: "[]"
    };
    this.http.post("/api/Hotels/GetHotelPageData", param1).then(res => {
      this.hotelsList = [];
      res.rows.forEach(item => {
        let obj = {
          value: item.hotel_Name,
          key: item.hotelid
        };
        this.hotelsList.push(obj);
        this.$set(hotelid, "data", this.hotelsList);
      });
    });
  },
  methods: {
    // 打开新建页面生成唯一标识
    algorithm() {
      let abc = [
        "a",
        "b",
        "c",
        "d",
        "e",
        "f",
        "g",
        "h",
        "i",
        "g",
        "k",
        "l",
        "m",
        "n",
        "o",
        "p",
        "q",
        "r",
        "s",
        "t",
        "u",
        "v",
        "w",
        "x",
        "y",
        "z"
      ];
      let [max, min] = [
        Math.floor(Math.random() * (10 - 7 + 1) + 1),
        Math.floor(Math.random() * (17 - 10 + 1) + 17)
      ];
      abc = abc
        .sort(() => 0.4 - Math.random())
        .slice(max, min)
        .slice(0, 8)
        .join("");
      var a = new Date().getTime() + abc;
      this.keyId = a;
      // return a
    },
    selectProduct() {
      if (this.productType == 2) {
        this.formFileds4.distributionid = this.formFileds3.distributorCode;
      } else if (this.productType == 1) {
        this.formFileds3.distributorCode = this.formFileds4.distributionid;
      } else if (this.productType == 3) {
        this.campList = [];
        this.http
          .get("/api/Distributors/GetDistributorAndType?type=" + 2004)
          .then(res => {
            let newarr = res.data.map(function(item, index, arr0) {
              return {
                key: item.distributorCode,
                value: item.distributorName
              };
            });
            let distributorCode = this.formRules7[0][0];
            this.$set(distributorCode, "data", newarr);
            distributorCode.onChange = (n, o) => {
              this.http
                .get(
                  `/api/distriProducts/GetProductsAndType?type=YingDi&distributionid=${n}`
                )
                // campList
                .then(res => {
                  if (res.data) {
                    this.treeProtyLISTS = res.data;
                  }
                });
            };
          });
      }
    },
    handleSelection(val) {
      this.infoFilter = [];
      this.infoFilter = val;
    },
    campAdd() {
      let obj = {
        detailData: null,
        delKeys: null,
        mainData: {
          ...this.formFields12
        }
      };
      // 新增
      if (this.campID == "") {
        this.http
          .post("api/CampsitePeople/AddCampPeopleInfo", obj)
          .then(res => {
            if (res) {
              this.http
                .get(
                  `/api/CampsitePeople/GetCampPeopleAndIdCard?IdCard=${this.formFields12.IdCard}&parentsPhone=${this.formFields12.parentsPhone}`
                )
                .then(res => {
                  if (res.data && res.data.length > 0) {
                    let obj1 = res.data[0];
                    let obj = {
                      id: obj1.id,
                      id_card: obj1.idCard,
                      name: obj1.name,
                      phone: obj1.parentsPhone
                    };
                    this.researchersInfo.unshift(obj);
                  }
                });
            } else {
              this.$Message.error(res.message);
            }
          });
      } else {
        // 修改
        obj.mainData.id = this.campID;
        this.campID = "";
        this.http
          .post("api/CampsitePeople/UpdateCampPeopleInfo", obj)
          .then(res => {
            if (res) {
              this.http
                .get(
                  `/api/CampsitePeople/GetCampPeopleAndIdCard?IdCard=${this.formFields12.IdCard}&parentsPhone=${this.formFields12.parentsPhone}`
                )
                .then(res => {
                  if (res.data && res.data.length > 0) {
                    let obj1 = res.data[0];
                    let obj = {
                      id: obj1.id,
                      id_card: obj1.idCard,
                      name: obj1.name,
                      phone: obj1.parentsPhone
                    };
                    this.researchersInfo.unshift(obj);
                  }
                });
            } else {
              this.$Message.error(res.message);
            }
          });
      }
    },
    getSelecte() {
      let userTypeInfo = JSON.parse(
        sessionStorage.getItem("sessionStorageUSER")
      );
      if (userTypeInfo.userType != "2") {
        this.checkrows = this.$refs.CouponMemberTable.getSelected();
        this.changeZH = "2";
        this.couponidNum = this.checkrows[0].couponid;
        if (this.checkrows[0].type == 1 && this.checkrows[0].use_type == 1) {
          this.changeTotalNum =
            this.changeNum2 - this.checkrows[0].coupon_value;
        } else if (
          this.checkrows[0].type == 2 &&
          this.checkrows[0].use_type == 1
        ) {
          try {
            this.goodTableData.forEach(item => {
              if (item.goods_id == this.checkrows[0].product_id) {
                this.goodprice = item.price;
                let merchandiseDiscount = this.changeNum2 - this.goodprice;
                this.changeTotalNum = merchandiseDiscount;
                throw new Error("LoopInterrupt");
              } else {
                this.changeTotalNum = this.changeNum2;
              }
            });
          } catch (e) {
            if (e.message !== "LoopInterrupt") throw e;
          }
        } else if (this.checkrows[0].type == 3) {
          if (this.checkrows[0].use_type == 1) {
            this.changeTotalNum =
              this.changeNum2 * (this.checkrows[0].coupon_value * 0.1);
          } else if (this.checkrows[0].use_type == 2) {
          } else if (this.checkrows[0].use_type == 3) {
            let newgood = this.goodTableData.filter(function(
              item,
              index,
              arr0
            ) {
              return item.goods_id == this.checkrows[0].product_id;
            });
            let merchandiseDiscount =
              this.changeNum2 -
              newgood[0].price * (1 - this.checkrows[0].coupon_value * 0.1);
            this.changeTotalNum = merchandiseDiscount;
          } else {
            this.changeTotalNum = this.changeNum2;
          }
        } else if (
          this.checkrows[0].type == 4 &&
          this.checkrows[0].use_type == 1
        ) {
          this.changeTotalNum =
            this.changeNum2 - this.checkrows[0].coupon_value;
        } else {
          this.changeTotalNum = this.changeNum2;
        }
      }
    },
    renderFunc(h, option) {
      return option.name.length > 1 ? (
        <el-tooltip effect="light" content={option.goodcode} placement="top">
          <span>{option.name}</span>
        </el-tooltip>
      ) : (
        <span>{option.name}</span>
      );
    },
    renderFuncName(h, option) {
      return option.name.length > 10 ? (
        <el-tooltip effect="light" content={option.name} placement="top">
          <span>{option.name}</span>
        </el-tooltip>
      ) : (
        <span>{option.name}</span>
      );
    },

    selectasghdjks(ee) {
      let sum = 0;
      let sum2 = 0;
      this.goodTableData.forEach(res => {
        sum += res.price * res.num;
        sum2 += res.secondprice * res.num;
      });
      this.changeNum = sum;
      this.changeNum2 = sum2;
    },
    searchInfo() {
      if (this.formFields1.bookingPhone == "") {
        this.$Message.error("请输入手机号点击查询或查询条件为空");
      } else {
        if (this.formFields1.bookingPhone.length == 11) {
          let param = {
            order: "desc",
            page: 1,
            rows: 30,
            sort: "",
            wheres: `[{\"name\":\"phone\",\"value\":\"${this.formFields1.bookingPhone}\",\"displayType\":\"text\"}]`
          };

          this.http
            .post("/api/SmallUserArchives/GetSmallUserPageData", param)
            .then(res => {
              if (res.rows.length != 0) {
                this.creatID = res.rows[0].id;

                if (this.userparameter == 0) {
                  this.formFields2.name = res.rows[0].name;
                  this.formFields2.phone = res.rows[0].phone;
                  this.formFields2.id_card = res.rows[0].id_card;
                  this.formFields2.certificate_type =
                    res.rows[0].certificate_type;
                } else {
                  this.formFields1.bookingName = res.rows[0].name;
                  this.formFields1.bookingPhone = res.rows[0].phone;
                  this.formFields1.bookingIdCard = res.rows[0].id_card;
                  this.formFields1.certificate_type =
                    res.rows[0].certificate_type;
                }
              } else {
                if (this.userparameter == 0) {
                  this.formFields2.name = "";
                  this.formFields2.id_card = "";
                  this.formFields2.certificate_type = "";
                } else {
                  this.formFields1.bookingName = "";
                  this.formFields1.bookingIdCard = "";
                  this.formFields1.certificate_type = "";
                }
              }
            });
        } else {
          this.$Message.error("手机号输入错误");
        }
      }
    },
    campSearch() {
      let phone = this.formFields12.parentsPhone;
      this.http
        .get(
          `/api/CampsitePeople/GetCampPeopleAndIdCard?IdCard=${this.formFields12.IdCard}&parentsPhone=${this.formFields12.parentsPhone}`
        )
        .then(res => {
          if (res.data && res.data.length > 0) {
            let obj = res.data[0];
            // 姓名
            this.formFields12.name = obj.name;
            this.campID = obj.id || "";
            this.formFields12.IdCardType = "" + obj.idCardType;
            // 身份证
            this.formFields12.IdCard = obj.idCard;
            this.formFields12.parentsPhone = obj.parentsPhone;
            this.formFields12.gender = obj.gender;
            this.formFields12.height = obj.height;
            this.formFields12.remarks = obj.remarks;
            this.formFields12.skiLevel = obj.skiLevel;
            this.formFields12.weight = obj.weight;
          } else {
            this.campID = "";
            this.$refs.myformuser.reset();
            this.formFields12.parentsPhone = phone;
          }
        });
    },
    searchUseinfo() {
      if (this.formFields2.phone == "") {
        this.$Message.error("请输入手机号点击查询或查询条件为空");
      } else {
        if (this.formFields2.phone.length == 11) {
          let param = {
            order: "desc",
            page: 1,
            rows: 30,
            sort: "",
            wheres: `[{\"name\":\"phone\",\"value\":\"${this.formFields2.phone}\",\"displayType\":\"text\"}]`
          };
          this.http
            .post("/api/SmallUserArchives/GetSmallUserPageData", param)
            .then(res => {
              if (res.rows.length != 0) {
                if (this.userparameter == 0) {
                  this.formFields2.name = res.rows[0].name;
                  this.formFields2.phone = res.rows[0].phone;
                  this.formFields2.id_card = res.rows[0].id_card;
                  this.formFields2.certificate_type =
                    res.rows[0].certificate_type;
                } else {
                  this.formFields2.name = res.rows[0].name;
                  this.formFields2.phone = res.rows[0].phone;
                  this.formFields2.id_card = res.rows[0].id_card;
                  this.formFields2.certificate_type =
                    res.rows[0].certificate_type;
                }
              } else {
                if (this.userparameter == 0) {
                  this.formFields2.name = "";
                  this.formFields2.id_card = "";
                  this.formFields2.certificate_type = "";
                } else {
                  this.formFields2.name = "";
                  this.formFields2.id_card = "";
                  this.formFields2.certificate_type = "";
                }
              }
            });
        } else {
          this.$Message.error("手机号输入错误");
        }
      }
    },
    getOption(field) {
      let option;
      this.formRules1.forEach(x => {
        x.forEach(item => {
          if (item.field == field) {
            option = item;
          }
        });
      });
      return option;
    },
    getOption3(field) {
      let option;
      this.formRules3.forEach(x => {
        x.forEach(item => {
          if (item.field == field) {
            option = item;
          }
        });
      });
      return option;
    },
    getOption4(field) {
      let option;
      this.formRules4.forEach(x => {
        x.forEach(item => {
          if (item.field == field) {
            option = item;
          }
        });
      });
      return option;
    },
    getOptionly(field) {
      let option;
      this.formRulesly.forEach(x => {
        x.forEach(item => {
          if (item.field == field) {
            option = item;
          }
        });
      });
      return option;
    },

    // 删除
    delgood(v) {
      let sum = 0;
      let sum2 = 0;
      this.goodTableData.forEach((item, index) => {
        if (v == item.id) {
          this.goodTableData.splice(index, 1);
          sum += item.price * item.num;
          sum2 += item.secondprice * item.num;
        }
      });
      let sums = sum.toFixed(2);
      let sums2 = sum2.toFixed(2);
      this.changeNum -= sums;
      this.changeNum2 -= sums2;
    },

    deluser(v) {
      this.researchersInfo.forEach((item, index) => {
        if (v == item.phone) {
          this.researchersInfo.splice(index, 1);
        }
      });
    },
    // 使用人
    userButton(v, n) {
      if (this.productType == 3) {
        this.model.box12 = true;
      } else {
        this.model.box6 = true;
      }
      this.userparameter = n;
      this.userNum = v;
      this.researchersInfo = [];
      this.formFields2.name = "";
      this.formFields2.phone = "";
      this.formFields2.certificate_type = "";
      this.formFields2.id_card = "";
      this.researchersInfo = this.userNum.selectionArr;
      if (this.goodSelectNum == "1") {
        this.goodsSelected();
      } else {
        this.otherSelected();
      }
    },
    //点击确认表单没有数据的时候
    goodsSelected() {
      if (this.userNum.children.length != 0) {
        if (
          this.userNum.children.length == 1 &&
          this.userNum.selectionArr.length == 1
        ) {
          this.$nextTick(() => {
            this.$refs.researchersInfoTable.toggleAllSelection();
          });
        } else {
          this.$nextTick(() => {
            this.userNum.children.forEach(i => {
              this.$refs.researchersInfoTable.toggleRowSelection(i, true);
            });
          });
        }
      }
    },
    // 点击确认表单有数据的时候
    otherSelected() {
      this.$refs.researchersInfoTable.clearSelection();
      if (this.researchersInfo.length == 1) {
        this.$refs.researchersInfoTable.toggleAllSelection();
      } else {
        this.researchersInfo.forEach((i, index) => {
          // if (!(this.researchersInfo.length - 1 == index)) {
          if (index == 0) {
            this.$refs.researchersInfoTable.toggleRowSelection(i, true);
          }
        });
      }
    },
    researcherCom() {
      this.formFields2.distributorCode = this.formFileds3.distributorCode;
      this.formFields2.nickname = this.formFields2.name;
      if (this.formFields2.phone.length == 11) {
        let param = {
          order: "desc",
          page: 1,
          rows: 30,
          sort: "",
          wheres: `[{\"name\":\"phone\",\"value\":\"${this.formFields2.phone}\",\"displayType\":\"like\"}]`
        };
        this.http
          .post("/api/SmallUserArchives/GetSmallUserPageData", param)
          .then(res => {
            if (this.formFields2.phone != "" && this.formFields2.name != "") {
              if (res.rows.length == 0) {
                let param = { mainData: this.formFields2 };
                this.http
                  .post("/api/SmallUserArchives/AddSmallUser", param)
                  .then(res => {
                    this.formFields2.name = "";
                    this.formFields2.phone = "";
                    this.formFields2.certificate_type = "";
                    this.formFields2.id_card = "";
                    if (res.status) {
                      // let researcher = res.data;
                      let researcherobj = res.data.data;
                      // JSON.parse(researcher).data;
                      let obj = {
                        id: researcherobj.id,
                        id_card: researcherobj.id_card,
                        name: researcherobj.name,
                        phone: researcherobj.phone
                      };
                      this.researchersInfo.unshift(obj);
                    }
                  });
              } else {
                if (this.researchersInfo.length == 0) {
                  let obj = {
                    id_card: this.formFields2.id_card,
                    name: this.formFields2.name,
                    phone: this.formFields2.phone
                  };
                  this.researchersInfo.unshift(obj);
                } else {
                  if (
                    !this.researchersInfo
                      .map(i => i.phone)
                      .includes(this.formFields2.phone)
                  ) {
                    let obj = {
                      id_card: this.formFields2.id_card,
                      name: this.formFields2.name,
                      phone: this.formFields2.phone
                    };
                    this.researchersInfo.unshift(obj);
                  }
                  this.researchersInfo.forEach(i => {
                    if (i.phone == this.formFields2.phone) {
                      i.name = this.formFields2.name;
                    }
                  });
                }
              }
            } else {
              this.$Message.error("必填项没有填写");
              return false;
            }
          });
      }
    },

    // 原来手工单方法
    researcherComBY() {
      let obj = {
        id_card: this.formFields2.id_card,
        name: this.formFields2.name,
        phone: this.formFields2.phone
      };
      this.researchersInfo.unshift(obj);
      this.formFields2.distributorCode = this.formFileds3.distributorCode;
      this.formFields2.nickname = this.formFields2.name;
      if (this.formFields2.phone.length == 11) {
        let param = {
          order: "desc",
          page: 1,
          rows: 30,
          sort: "",
          wheres: `[{\"name\":\"phone\",\"value\":\"${this.formFields2.phone}\",\"displayType\":\"like\"}]`
        };
        this.http
          .post("/api/SmallUserArchives/GetSmallUserPageData", param)
          .then(res => {
            if (this.formFields2.phone != "" && this.formFields2.name != "") {
              if (res.rows.length == 0) {
                let param = { mainData: this.formFields2 };
                this.http
                  .post("/api/SmallUserArchives/AddSmallUser", param)
                  .then(res => {
                    this.formFields2.name = "";
                    this.formFields2.phone = "";
                    this.formFields2.certificate_type = "";
                    this.formFields2.id_card = "";
                    if (res.status) {
                      // let researcher = res.data;
                      // let researcherobj = JSON.parse(researcher).data;
                      let researcherobj = res.data.data;
                      let obj = {
                        id: researcherobj.id,
                        id_card: researcherobj.id_card,
                        name: researcherobj.name,
                        phone: researcherobj.phone
                      };
                      this.researchersInfo.unshift(obj);
                    }
                  });
              } else {
                if (this.researchersInfo.length == 0) {
                  let obj = {
                    id_card: this.formFields2.id_card,
                    name: this.formFields2.name,
                    phone: this.formFields2.phone
                  };
                  this.researchersInfo.unshift(obj);
                } else {
                  if (
                    !this.researchersInfo
                      .map(i => i.phone)
                      .includes(this.formFields2.phone)
                  ) {
                    let obj = {
                      id_card: this.formFields2.id_card,
                      name: this.formFields2.name,
                      phone: this.formFields2.phone
                    };
                    this.researchersInfo.unshift(obj);
                  }
                  this.researchersInfo.forEach(i => {
                    if (i.phone == this.formFields2.phone) {
                      i.name = this.formFields2.name;
                    }
                  });
                }
              }
            } else {
              this.$Message.error("必填项没有填写");
              return false;
            }
          });
      }
    },
    // 正常下单点击确认默认选中添加的数据
    closebox6() {
      this.changeAll = "2";
      if (this.formFields1.teamScheduled == 0) {
        if (
          !(this.userNum.num == this.infoFilter.length) &&
          this.infoFilter.length != 1
        ) {
          this.$Message.error("使用人与数量不符或者一个使用可以对应多个数量");
          return;
        }
        if (this.formFields2.name != "") {
          this.userNum.useRen = this.formFields2.name;
          this.researcherComBY();
        }
        if (this.formFields2.name == "" && this.formFields2.phone == "") {
          this.goodSelectNum = "1";
          this.goodsSelected();
        } else {
          this.goodSelectNum = "2";
          this.otherSelected();
        }
      } else {
        this.userNum.useRen = this.userNum.children[0].name;
      }
      this.userNum.children = [];
      this.userNum.children = this.infoFilter;
      this.model.box6 = false;
    },
    isRepeat(arr) {
      var hash = {};
      for (var i in arr) {
        if (hash[arr[i].id]) {
          return true;
        }
        hash[arr[i].id] = true;
      }
      return false;
    },

    // 夏令营点击确认默认选中添加的数据
    closebox7() {
      this.changeAll = "2";
      let isRepeat = this.isRepeat(this.infoFilter);
      if (this.formFields1.teamScheduled == 0) {
        if (this.infoFilter.length != 1) {
          if (this.userNum.people_num != this.infoFilter.length) {
            if (isRepeat) {
              this.$Message.error(
                "使用人与数量不符或者一个使用可以对应多个数量"
              );
              return;
            }
          }
        }
        if (this.formFields12.name != "") {
          let str = "";
          this.infoFilter.forEach(item => {
            str += item.name + ",";
          });
          this.userNum.useRen = str;
        }
        if (this.formFields12.name == "") {
          this.goodSelectNum = "1";
          this.goodsSelected();
        } else {
          this.goodSelectNum = "2";
          this.otherSelected();
        }
      } else {
        // this.userNum.useRen = this.userNum.children[0].name;
        let str = "";
        this.infoFilter.forEach(item => {
          str += item.name + ",";
        });
        this.userNum.useRen = str;
      }
      this.userNum.children = [];
      this.userNum.children = this.infoFilter;
      this.model.box12 = false;
    },
    uploadAfter(result) {
      let param = {
        filepath: result.data,
        disCode: this.formFileds3.distributorCode
      };
      this.http
        .post("api/SmallUserArchives/ImportSmallUser", param)
        .then(res => {
          this.researchersInfo = res.data;
          if (res.status) {
            this.$Message.success(res.message);
          } else {
            this.$Message.error(res.message);
          }
        });
      return true;
    },
    // 下载模版
    downloadExcel() {
      let a = document.createElement("a");
      a.href =
        "https://api.boss.i-town.cn/api/SmallUserArchives/DownLoadUserTemplate";
      //"http://192.168.1.47:9991/api/SmallUserArchives/DownLoadUserTemplate";
      a.download = "文件模板.xls";
      a.style.display = "none";
      document.body.appendChild(a);
      a.click();
      a.remove();
    },
    // 夏令营下单
    campsubmit(editFormFields) {
      if (this.infoFilter.length != 1) {
        if (this.userNum.people_num != this.infoFilter.length) {
          this.$Message.error("使用人与数量不符或者一个使用可以对应多个数量");
          return;
        }
      }
      this.$refs.formFieldsreset.validate(() => {
        let list = [];
        if (this.goodTableData.length != 0) {
          let obj = this.goodTableData[0];
          if (obj.selectionArr.length != 0) {
            obj.selectionArr.forEach(item => {
              if (item.id) {
                list.push(item.id);
              }
            });
          }
          let param = {
            good_id: obj.goodid,
            good_num: obj.num,
            campsitePeople_ids: list,
            distributorCode: this.formFileds5.distributorCode,
            bookingPhone: this.formFields1.bookingPhone,
            bookingName: this.formFields1.bookingName,
            bookingIdCard: this.formFields1.bookingIdCard,
            bookingType: this.formFields1.certificate_type,
            user_id: this.creatID,
            reservationType: this.formFields1.reservationType,
            account_code_fk: this.formFields1.reserveValue
          };
          this.http.post("api/VSmallOrders/OrderCampAdd", param).then(res => {
            if (res.status) {
              this.model.box3 = false;
              this.loading = false;
              this.$Message.success("添加成功");
              this.$store.getters.data().viewPageTest.refresh();
            } else {
              this.loading = false;
              this.$Message.error(res.message);
            }
          });
        }
      });
    },
    submit(editFormFields) {
      //游客， 团队 团进团出 团进散出
      let userTypeInfo = JSON.parse(
        sessionStorage.getItem("sessionStorageUSER")
      );

      var rows = this.$refs.CouponMemberTable.getSelected();
      if (userTypeInfo.userType != "2" && this.formFields1.bookingName == "") {
        this.$Message.error("请输入名字");
        return;
      }
      if (this.formFields1.teamScheduled == 0) {
        // 散客
        let arr = [];
        console.log(this.goodTableData);
        this.goodTableData.forEach(res => {
          let goods_id = res.goods_id;
          let title = res.title;
          let price = res.price;
          let num = res.num;
          let pic_path = res.pic_path;
          let verificationrulesid = res.verificationrulesid;
          let secondprice = res.secondprice;
          let obj = {
            title: title,
            price: price,
            num: num,
            pic_path: pic_path,
            goods_id: goods_id,
            playStartDate:
              this.productType == "1"
                ? this.formFileds3.date
                : this.formFileds4.date[0],
            playEndDate:
              this.productType == "1"
                ? this.formFileds3.date
                : this.formFileds4.date[1],
            reservationType: this.formFields1.reservationType,
            account_code_fk: this.formFields1.reserveValue,
            verificationrulesid: verificationrulesid,
            secondprice: secondprice,
            priceSecond: secondprice
          };
          res.children.forEach(member => {
            obj.name = member.name;
            obj.phone = member.phone;
            obj.id_card = member.id_card;
            obj.user_id = member.id;
            delete obj.children;
          });
          arr.push(obj);
        });
        let smallorderlist = {
          // 券前订单金额
          orderPrice: this.changeNum,
          orderSecondPrice: this.changeNum2,
          // 券后订单总金额
          order_total_price:
            this.changeZH == "1"
              ? this.changeNum.toFixed(2)
              : this.changeTotalNum.toFixed(2),
          order_total_second_price:
            this.changeZH == "1"
              ? this.changeNum2.toFixed(2)
              : this.changeTotalNum.toFixed(2),
          coupon_number: this.couponidNum,
          bookingPhone: this.formFields1.bookingPhone,
          bookingName: this.formFields1.bookingName,
          bookingIdCard: this.formFields1.bookingIdCard,
          bookingType: this.formFields1.certificate_type,
          reservationType: this.formFields1.reservationType,
          external_order_number1: this.formFields1.external_order_number1,
          spare14: this.formFields1.spare14,
          distributorCode:
            this.productType == "1"
              ? this.formFileds3.distributorCode
              : this.formFileds4.distributionid,
          Small_order_item_second: arr,
          sourceid_distributor: this.formly.sourceid_distributor
        };
        let param = {
          smallorder: [smallorderlist],
          goodList: this.goodTableData,
          account_code_fk: this.formFields1.reserveValue,
          productType: this.productType,
          ordermanually: 0,
          coupon: rows[0] || ""
        };
        this.loading = true;
        this.http
          .post("/api/VSmallOrders/SubmitOrderSecond", param)
          .then(res => {
            if (res.status) {
              this.model.box3 = false;
              this.loading = false;
              this.$Message.success(res.message);
              this.$store.getters.data().viewPageTest.refresh();
            } else {
              this.loading = false;
              this.$Message.error(res.message);
            }
          });
      }
    },
    handleSelectionChange(val) {
      var ids = [];
      this.selNum = val.length;
      for (var index in val) {
        ids.push(val[index].goods_id);
      }
      for (var i in this.goodTableData) {
        if (ids.indexOf(this.goodTableData[i].id) != -1) {
          this.goodTableData[i].selected = 1;
        } else {
          this.goodTableData[i].selected = 0;
        }
      }
    },
    GetVueDictionary() {
      this.model.box3 = true;
      let param = [
        "Member_Type",
        "supplier",
        "reservationTypesimple",
        "manudistributorList"
      ];
      this.http.post("/api/Dictionary/GetVueDictionary", param).then(res => {
        this.reserveTypeList = [];
        this.distributorList = [];
        this.hylxList = [];
        this.treeProtype = [];
        res.forEach(o => {
          if (o.dicNo == "manudistributorList") {
            o.data.forEach(i => {
              let obj = {
                label: i.value,
                value: i.key
              };
              this.distributorList.push(obj);
            });
          }
          if (o.dicNo == "reservationTypesimple") {
            o.data.forEach(i => {
              let obj = {
                label: i.value,
                value: i.key
              };
              this.reserveTypeList.push(obj);
            });
          } else if (o.dicNo == "Member_Type") {
            o.data.forEach(i => {
              let obj = {
                label: i.value,
                value: i.key,
                key: i.key
              };
              this.hylxList.push(obj);
            });
          } else if (o.dicNo == "supplier") {
            o.data.forEach(i => {
              let obj = {
                label: i.value,
                value: i.key,
                key: i.key
              };
              this.MerchantLIST.push(obj);
            });
          }
        });
      });
    },
    campChange(val) {
      this.treeProtyLISTS.forEach(item => {
        if (item.productid == val[0]) {
          this.campList = item.mall_distri_good.map(items => {
            return {
              label: items.spare1,
              value: items.goodid,
              key: items.id,
              price: items.preferentialPrice,
              num: 1,
              id: items.id,
              goodid: items.id,
              productName: item.productName,
              people_num: items.spare7 || "1"
            };
          });
        }
      });
    },
    changeCasc(val) {
      var last = val.length;
      if (this.formFileds3.distributorCode != "") {
        this.http
          .post("/api/Mall_good/GetMallGoodsSecond", {
            tpyeid: val[last - 1],
            distributionid: this.formFileds3.distributorCode,
            date: this.formFileds3.date,
            phone: this.formFields1.bookingPhone
          })
          .then(res => {
            this.productsList = [];
            let arr = [];
            if (res.data.length != 0) {
              res.data.forEach(i => {
                let obj = {
                  label: i.name,
                  value: i.goods_id,
                  key: i.goods_id,
                  ...i
                };
                arr.push(obj);
              });
              this.productsList.push(...arr);
            }
          });
      } else {
        this.$Message.error("请先选择分销商");
      }
    },
    rowClick({ row, column, event }) {
      //table点击行时同时选中当前行
      this.$refs.goodlisttable.$refs.table.toggleRowSelection(row);
      return true;
    },
    getForm() {
      if (!this.$refs.myform.validate()) {
        return;
      }
      let formData = {
        mainData: this.formFileds,
        detailData: this.$refs.tables.tableData,
        delKeys: null
      };
      let _this = this;
      this.http.post("api/small_order/Add", formData, true).then(x => {
        if (!x.status) return this.$message.error(x.message);
        this.$message.success(x.message);
        this.tableData = [];
        this.$refs.myform.reset();

        _this.$parent.refresh();
        _this.$parent.refreshRow();
      });
      this.model.box2 = false;
    },
    reset() {
      //重置表单，重置时可指定重置的值，如果没有指定重置的值，默认全部清空
      let data = { Variety: "1", AvgPrice: 888 };
      this.$refs.myform.reset(data);
      this.$message.error("表单已重置");
    },
    getFormOption(field) {
      let option;
      this.formRules.forEach(x => {
        x.forEach(item => {
          if (item.field == field) {
            option = item;
          }
        });
      });
      return option;
    },
    open1() {
      this.getinitDictionary();
      this.model.box2 = true;
    },
    open2() {
      this.GetVueDictionary();
      // var userTypeInfo = JSON.parse(localStorage.getItem("user"));
      var userTypeInfo = JSON.parse(
        sessionStorage.getItem("sessionStorageUSER")
      );
      if (userTypeInfo.userType == "2") {
        let userPhone = userTypeInfo.phone;
        let bookingIdCard = this.getOption("bookingIdCard");
        let certificate_type = this.getOption("certificate_type");
        let bookingName = this.getOption("bookingName");
        let bookingPhone = this.getOption("bookingPhone");
        let reservationType = this.getOption("reservationType");
        let reserveValue = this.getOption("reserveValue");
        let reserveValueName = this.getOption("reserveValueName");
        this.formRules1[0][1].hidden = true;
        this.formRules1[0][0].colSize = 5;
        reservationType.disabled = true;
        bookingIdCard.disabled = true;
        certificate_type.disabled = true;
        bookingName.disabled = true;
        bookingPhone.disabled = true;
        reserveValueName.hidden = false;
        reserveValueName.disabled = true;
        this.couponList = false;
        this.changeTotalNum = 0;
        this.changeNum = 0;
        this.changeNum2 = 0;
        this.changeZH = "1";
        this.changeAll = "1";
        this.formFileds4.date = "";
        this.formFileds4.stockNumebr = "1";
        this.formFileds4.hotelid = "";
        this.formFileds4.roomcode = "";
        // this.treeProtyLIST = [];
        this.cascaderValue = [];
        this.productsList = [];
        this.selectValue = [];
        this.GoodsHotelList = [];
        this.CouponMemberidData = [];
        this.goodTableData = [];
        let param = {};
        this.formFields1.teamScheduled = 0;
        let teamType = this.getOption("teamType");
        teamType.hidden = true;
        teamType.required = false;
        let user = JSON.parse(sessionStorage.getItem("sessionStorageUSER"));
        let url = "";
        if (user.userType == 2) {
          url = "api/SmallUserArchives/GetPcDistributorUser";
          param = {
            code: user.code,
            phone: user.phone
          };
        } else {
          url = "/api/SmallUserArchives/GetSmallUserPageData";
          param = {
            order: "desc",
            page: 1,
            rows: 30,
            sort: "",
            wheres: `[{\"name\":\"phone\",\"value\":\"${userPhone}\",\"displayType\":\"text\"}]`
          };
        }
        this.http.post(url, param).then(res => {
          if (res.rows.length > 0) {
            this.formFields1.bookingIdCard = res.rows[0].id_card;
            this.formFields1.certificate_type = res.rows[0].certificate_type;
            this.formFields1.bookingName = res.rows[0].name;
            this.formFields1.bookingPhone = res.rows[0].phone;
            this.formFields1.reservationType = "7";
          }
          if (res.rows.length != 0) {
            // let user = JSON.parse(localStorage.getItem("user"));
            let user = JSON.parse(sessionStorage.getItem("sessionStorageUSER"));
            let code = "";
            if (user.userType == 2) {
              code = user.code;
            } else {
              code = res.rows[0].distributorCode;
            }
            let param = {
              code: code || ""
            };
            this.http
              .post("/api/AccountsMain/GetAccountsByDistri", param)
              .then(res => {
                if (res.data.length > 0) {
                  this.formFields1.reserveValue = res.data[0].account_code_fk;
                  this.formFields1.reserveValueName = res.data[0].account_name;
                }
              });
          }
        });
      } else {
        this.goodTableData = [];
        this.formFields1.bookingPhone = "";
        this.formFields1.bookingName = "";
        this.formFields1.bookingType = "";
        this.formFields1.bookingIdCard = "";
        this.formFields1.reserveValue = "";
        this.formFields1.reservationType = 4;
        this.formFields1.teamScheduled = 0;
        this.formFileds3.date = "";
        this.formFileds3.distributorCode = "";
        this.formFields1.certificate_type = "";
        this.formFields1.spare14 = "";
        this.userparameter = 1;
        this.formFileds4.distributionid = "";
        this.formFileds4.date = "";
        this.formFileds4.stockNumebr = "1";
        this.formFileds4.hotelid = "";
        this.formFileds4.roomcode = "";
        this.changeTotalNum = 0;
        this.changeNum = 0;
        this.changeNum2 = 0;
        this.changeZH = "1";
        this.changeAll = "1";
        // this.treeProtyLIST = [];
        this.cascaderValue = [];
        this.productsList = [];
        this.selectValue = [];
        this.GoodsHotelList = [];
        this.CouponMemberidData = [];
        let teamType = this.getOption("teamType");
        teamType.hidden = true;
        teamType.required = false;
        let reserveValue = this.getOption("reserveValue");
        reserveValue.hidden = true;
        reserveValue.required = false;
      }
    },
    getly(v) {

      let sourceid_distributor = this.getOptionly("sourceid_distributor");
      let paramfxs = {
        order: "desc",
        page: 1,
        rows: 100,
        sort: "id",
        wheres: `[{\"name\":\"distributorCode\",\"value\":\"${v}\",\"displayType\":\"text\"}]`
      };
      this.http
        .post("/api/Distributors/GetDistributorList", paramfxs)
        .then(res => {
          if (
            res.rows[0].distributorType == 2002 &&
            res.rows[0].merchantCode == "FuLongSiJiXiaoZhen"
          ) {
            this.flxjxzly = true;
            sourceid_distributor.required = true
          } else {
            this.flxjxzly = false;
            sourceid_distributor.required = false
          }
        });
      let param = {
        order: "desc",
        page: 1,
        rows: 100,
        sort: "id",
        wheres: `[{\"name\":\"distributorCode\",\"value\":\"${v}\",\"displayType\":\"text\"}]`
      };

      this.http
        .post("/api/Mall_distributor_source/GetSourcePageData", param)
        .then(res => {
          if (res.rows.length > 0) {
            sourceid_distributor.data = res.rows.map(i => {
              return {
                key: i.id,
                value: i.sourceName
              };
            });
          }
        });
    },
    open3() {
      if (
        !this.formFields1.bookingPhone ||
        !/^[1][3,4,5,6,7,8,9][0-9]{9}$/.test(this.formFields1.bookingPhone)
      ) {
        this.$message({
          type: "warning",
          message: "请检查手机号是否填写完整!"
        });
        return;
      }
      this.GetVueDictionary();
      // 产品分销商
      let distributorCode = this.getOption3("distributorCode");
      this.formFileds3.distributorCode = distributorCode.data[0].key;
      this.getly(distributorCode.data[0].key || '')
      // 酒店分销编码
      let distributionid = this.getOption4("distributionid");
      this.formFileds4.distributionid = distributionid.data[0].key;
      this.formFileds4.date = "";
      this.formFileds4.stockNumebr = "1";
      this.formFileds4.hotelid = "";
      this.formFileds4.roomcode = "";
      this.productsList = [];
      this.selectValue = [];
      this.cascaderValue = [];
      this.GoodsHotelList = [];
      this.formFileds3.date = "";
      this.model.box4 = true;
    },

    open5() {
      let goods_id = [];
      this.goodTableData.forEach(item => {
        goods_id.push(item.goods_id);
      });
      if (!this.formFields1.bookingPhone || !goods_id.length) {
        this.$message({
          type: "warning",
          message: "请检查手机号和商品结算信息是否填写完整!"
        });
        return;
      }
      let param = {
        phone: this.formFields1.bookingPhone,
        goodList: goods_id
      };
      this.http.post("api/MebCouponhis/CouponMemberid ", param).then(res => {
        res.data.forEach(item => {
          if (item.productList != null) {
            item.productList.forEach(itemchildren => {
              item.product_id = itemchildren.product_id;
              item.product_name = itemchildren.product_name;
            });
          }
        });
        this.CouponMemberidData = res.data;
      });
      let param1 = ["MebHisUseStatus", "Coupon_Type", "Member_Type"];
      this.http.post("/api/Dictionary/GetVueDictionary", param1).then(res => {
        res.forEach(i => {
          if (i.dicNo == "Coupon_Type") {
            this.CouponMemberid.forEach(j => {
              if (j.field == "type") {
                j.bind.data = i.data;
              }
            });
          }
        });
      });
    },
    closeChild() {
      let G_selectValue = this.selectValue.join(",");
      if (this.productType == 1) {
        this.http
          .post("/api/Mall_good/GetMallGoodsSecondIn", {
            goodids: G_selectValue,
            distributionid: this.formFileds3.distributorCode,
            date: this.formFileds3.date,
            phone: this.formFields1.bookingPhone
          })
          .then(res => {
            if (res.status) {
              console.log(JSON.stringify(res.data));
              let sum = 0;
              let sum2 = 0;
              if (
                this.formFields1.bookingName != "" &&
                this.formFields1.bookingPhone != ""
              ) {
                res.data.forEach(o => {
                  let obj = {
                    goods_id: o.goods_id,
                    title: o.name,
                    price: o.price,
                    num: 1,
                    total_fee: o.price * 1,
                    order_total_second_price: o.secondprice * 1,
                    pic_path: o.pic_path,
                    useRen: this.formFields1.bookingName,
                    sellingRulesid: o.sellingRulesid,
                    sellingRulesName: o.sellingRulesName,
                    stockNumebr: o.stockNumebr,
                    typeid: o.typeid,
                    stockid: o.stockid,
                    playStartDate: this.formFileds3.date,
                    playEndDate: this.formFileds3.date,
                    verificationrulesid: o.verificationrulesid,
                    goodtype: 0,
                    hotel_ID: o.hotel_ID,
                    children: [
                      {
                        id_card: this.formFields1.bookingIdCard,
                        name: this.formFields1.bookingName,
                        phone: this.formFields1.bookingPhone
                      }
                    ],
                    selectionArr: [
                      {
                        id_card: this.formFields1.bookingIdCard,
                        name: this.formFields1.bookingName,
                        phone: this.formFields1.bookingPhone
                      }
                    ],
                    secondprice: o.secondprice
                  };
                  sum += o.price * 1;
                  sum2 += o.secondprice * 1;
                  this.goodTableData.push(obj);
                });
                if (this.changeNum == 0 || this.changeNum2 == 0) {
                  this.changeNum = sum;
                  this.changeNum2 = sum2;
                  this.confirmNum = 2;
                } else if (this.confirmNum == 2) {
                  this.changeNum += sum;
                  this.changeNum2 += sum2;
                }
                this.model.box4 = false;
              } else {
                res.data.forEach(o => {
                  let obj = {
                    goods_id: o.goods_id,
                    title: o.name,
                    price: o.price,
                    num: 1,
                    total_fee: o.price * 1,
                    order_total_second_price: o.secondprice * 1,
                    goodtype: 0,
                    // id: new Date(),
                    hotel_ID: o.hotel_ID,
                    useRen: this.formFields1.bookingName,
                    sellingRulesid: o.sellingRulesid,
                    sellingRulesName: o.sellingRulesName,
                    stockNumebr: o.stockNumebr,
                    stockid: o.stockid,
                    typeid: o.typeid,
                    playStartDate: this.formFileds3.date,
                    playEndDate: this.formFileds3.date,
                    verificationrulesid: o.verificationrulesid,
                    children: [],
                    selectionArr: [],
                    secondprice: o.secondprice
                  };
                  sum += o.price * 1;
                  sum2 += o.secondprice * 1;
                  this.goodTableData.push(obj);
                });
                if (this.changeNum == 0 || this.changeNum2 == 0) {
                  this.changeNum = sum;
                  this.changeNum2 = sum2;
                  this.confirmNum = 2;
                } else if (this.confirmNum == 2) {
                  this.changeNum += sum;
                  this.changeNum2 += sum2;
                }
              }
              this.model.box4 = false;
            } else {
              this.productsList = [];
              // this.GoodsHotelList = [];
              this.selectValue = [];
              this.$Message.error(res.message);
              this.model.box4 = true;
            }
          });
      }
      // 夏令营
      else if (this.productType == 3) {
        if (this.goodTableData.length >= 1) {
          this.$Message.error("一次只能选1个");
          this.model.box4 = false;
          return;
        }

        let option = {};
        this.campList.forEach(item => {
          if (this.selectValue[0] == item.key) {
            option = item;
          }
        });
        let obj = {
          title: option.productName + option.label,
          priceCamp: option.price,
          num: 1,
          goodid: option.goodid,
          useRen: this.formFields1.bookingName,
          children: [],
          selectionArr: [],
          people_num: parseInt(option.people_num) || 1,
          secondprice: option.secondprice
        };
        this.goodTableData.push(obj);

        this.model.box4 = false;
      } else {
        this.http
          .post("/api/Mall_good/GetMallGoodsHotelIn", {
            goodids: G_selectValue,
            distributionid: this.formFileds4.distributionid,
            startDate: this.formFileds4.date[0],
            endDate: this.formFileds4.date[1],
            arrTime: this.formFileds4.date[0],
            depTime: this.formFileds4.date[1],
            phone: this.formFields1.bookingPhone,
            stockNumebr: this.formFileds4.stockNumebr,
            hotelid: this.formFileds4.hotelid,
            roomcode: this.formFileds4.roomcode
          })
          .then(res => {
            if (res.status) {
              let sum = 0;
              let sum2 = 0;
              if (
                this.formFields1.bookingName != "" &&
                this.formFields1.bookingPhone != ""
              ) {
                res.data.forEach(o => {
                  let obj = {
                    goods_id: o.goods_id,
                    title: o.name,
                    price: o.price,
                    num: this.formFileds4.stockNumebr,
                    total_fee: o.price * 1,
                    order_total_second_price: o.secondprice * 1,
                    goodcount: o.goodcount,
                    minprice: o.minprice,
                    pic_path: o.pic_path,
                    useRen: this.formFields1.bookingName,
                    sellingRulesid: o.sellingRulesid,
                    sellingRulesName: o.sellingRulesName,
                    stockNumebr: this.formFileds4.stockNumebr,
                    typeid: o.typeid,
                    stockid: o.stockid,
                    verificationrulesid: o.verificationrulesid,
                    goodtype: 1,
                    playStartDate: this.formFileds4.date[0],
                    playEndDate: this.formFileds4.date[1],
                    arrTime: this.formFileds4.date[0],
                    depTime: this.formFileds4.date[1],
                    goodcode: o.goodcode,
                    children: [
                      {
                        id_card: this.formFields1.bookingIdCard,
                        name: this.formFields1.bookingName,
                        phone: this.formFields1.bookingPhone
                      }
                    ],
                    selectionArr: [
                      {
                        id_card: this.formFields1.bookingIdCard,
                        name: this.formFields1.bookingName,
                        phone: this.formFields1.bookingPhone
                      }
                    ],
                    stockList: o.stockList,
                    secondprice: o.secondprice,
                    priceSecond: o.secondprice
                  };
                  sum += o.price * this.formFileds4.stockNumebr;
                  sum2 += o.secondprice * this.formFileds4.stockNumebr;
                  this.goodTableData.push(obj);
                });
                if (this.changeNum == 0 || this.changeNum2 == 0) {
                  this.changeNum = sum;
                  this.changeNum2 = sum2;
                  this.confirmNum = 2;
                } else if (this.confirmNum == 2) {
                  this.changeNum += sum;
                  this.changeNum2 += sum2;
                }
                this.model.box4 = false;
              } else {
                res.data.forEach(o => {
                  let obj = {
                    goods_id: o.goods_id,
                    title: o.name,
                    price: o.price,
                    num: this.formFileds4.stockNumebr,
                    total_fee: o.price * 1,
                    order_total_second_price: o.secondprice * 1,
                    minprice: o.minprice,
                    goodcount: o.goodcount,
                    useRen: this.formFields1.bookingName,
                    sellingRulesid: o.sellingRulesid,
                    sellingRulesName: o.sellingRulesName,
                    stockNumebr: this.formFileds4.stockNumebr,
                    stockid: o.stockid,
                    typeid: o.typeid,
                    playStartDate: this.formFileds4.date[0],
                    playEndDate: this.formFileds4.date[1],
                    goodcode: o.goodcode,
                    children: [],
                    selectionArr: [],
                    stockList: o.stockList,
                    goodtype: 1,
                    secondprice: o.secondprice
                  };
                  sum += o.price * this.formFileds4.stockNumebr;
                  sum2 += o.secondprice * this.formFileds4.stockNumebr;
                  this.goodTableData.push(obj);
                });
                if (this.changeNum == 0 || this.changeNum2 == 0) {
                  this.changeNum = sum;
                  this.changeNum2 = sum2;
                  this.confirmNum = 2;
                } else if (this.confirmNum == 2) {
                  this.changeNum += sum;
                  this.changeNum2 += sum2;
                }
                this.model.box4 = false;
              }
            } else {
              this.GoodsHotelList = [];
              this.selectValue = [];
              this.formFileds4.date = "";
              this.$Message.error(res.message);
              this.model.box4 = true;
            }
          });
      }
    },
    getinitDictionary() {
      let distributor = this.getFormOption("distributor");
      let paytype = this.getFormOption("pay_type");
      this.http
        .post(
          "api/Dictionary/GetVueDictionary",
          ["manudistributorList", "reservationType"],
          false
        )
        .then(reslut => {
          let datas = [];
          reslut
            .find(item1 => item1.dicNo == "manudistributorList")
            .data.forEach(item1 => {
              let items = {};
              items.value = item1.value;
              items.key = item1.key;
              datas.push(items);
            });
          distributor.data = datas;
          let data1s = [];
          reslut
            .find(item1 => item1.dicNo == "reservationType")
            .data.forEach(item1 => {
              let items = {};
              items.value = item1.value;
              items.key = item1.key;
              data1s.push(items);
            });
          paytype.data = data1s;
        });
    }
  },
  data() {
    return {
      // 使用人ID
      campID: "",
      creatID: "",
      // 打开新建页面的唯一标识
      // 优惠券列表的显示隐藏
      keyId: "",
      confirmNum: "1",
      goodSelectNum: "1",
      goodTableZJ: [],
      couponList: true,
      disabledStatus: true,
      MainOrder: "",
      checkrows: [],
      infoFilter: [],
      changeAll: "1",
      changeZH: "1",
      // VSmallOrdersData: [],
      changeNum: 0,
      changeNum2: 0,
      changeTotalNum: 0,
      goodprice: 0,
      couponidNum: "",
      url: "/api/SmallUserArchives/Import",
      userNum: "",
      teamScheduledNum: "",
      handleChangeval: 1,
      specList: [],
      table1url: "",
      productType: "1",
      model: {
        box2: false,
        box1: false,
        box3: false,
        box4: false,
        box6: false,
        box12: false
      },
      tableData: [],
      goodTableData: [],
      options: [],
      reserveValue: "",
      loadKey: true,
      formFileds: {
        bookingPhone: "",
        bookingName: "",
        bookingIdCard: "",
        bookingType: "",
        playStartDate: "",
        reservationType: ""
      },
      formRules: [
        [
          {
            title: "预订人",
            required: true,
            field: "bookingName",
            type: "text",
            extra: {
              style: "color:green",
              icon: "ios-search", //显示图标
              text: "选择联系人", //显示文本
              //触发事件
              click: item => {
                this.$store.getters.data().chooserows = this.formFileds;
                this.$store.getters.data().formRules = this.formRules;
                this.model.box1 = true;
                this.$refs.choosereservation.open();

                // this.$refs.choosereservation.reset();
              }
            }
          },
          {
            title: "手机号",
            required: true,
            field: "bookingPhone",
            type: "phone"
          }
        ],
        [
          {
            title: "证件类型",
            field: "bookingType",
            type: "select",
            dataKey: "certificate_type",
            data: []
          },
          { title: "证件号", field: "bookingIdCard", type: "text" }
        ],
        [
          {
            title: "预定类型",
            required: true,
            field: "reservationType",
            type: "select",
            dataKey: "reservationType",
            data: []
          },
          {
            title: "分销商",
            field: "distributorCode",
            type: "select",
            dataKey: "distributorList",
            data: []
          }
        ],
        [
          {
            title: "游玩日期",
            required: true,
            field: "playStartDate",
            type: "date",
            range: true,
            extra: {
              style: "color:blue",
              icon: "ios-search", //显示图标
              text: "选择产品", //显示文本
              //触发事件
              click: item => {
                this.$store.getters.data().formFileds = this.formFileds;
                this.$store.getters.data().getGOODList = this;
                if (this.formFileds.playStartDate) {
                  this.$refs.choosegoods.open();
                } else {
                  this.$message.error("请先选择游玩日期！");
                }
              }
            }
          }
        ]
      ],
      tableColumns1: [
        {
          field: "name",
          title: "商品名称",
          type: "string",
          width: 220,
          align: "left",
          sortable: true,
          align: "left"
        },
        {
          field: "sellingPrice",
          title: "售价",
          type: "string",
          width: 90,
          align: "left"
        },
        {
          field: "number",
          title: "数量",
          type: "string",
          width: 90,
          align: "left",
          edit: { type: "number" }
        },
        {
          field: "preferentialPrice",
          title: "优惠价",
          type: "int",
          width: 90,
          align: "left"
        },
        {
          field: "productDate",
          title: "游玩时间",
          type: "datetime",
          width: 200,
          align: "left",
          sortable: true
        }
        // {field:'modifyID',title:'修改人ID',type:'int',width:90,hidden:true,align:'left'},
      ],
      show: true,
      researchersInfo: [],
      multipleSelection: [],
      title: "",
      userparameter: 1,
      editFormFields: {
        creator: "",
        createDate: "",
        bookingName: "", //预订人姓名
        bookingPhone: "", //预订手机号
        bookingIdCard: "", //预订人证件号
        reservationType: "", //预定类型
        teamScheduled: "0",
        order_total_price: "0",
        order_total_second_price: "0",
        distributorCode: "", //分销商code
        is_message: "1",
        teamType: "0",
        pay_type: "4",
        coupon_value: 0,
        count: "",
        applicable_people: "",
        useTime: "",
        member_type: "",
        member_level: "",
        threshold_value: "",
        amount_condition: 0
      },
      loading: false,
      distributorList: [],
      reserveTypeList: [],
      hotelsList: [],
      roomList: [],
      rqStatus: false,
      hylxList: [],
      hydjList: [],
      treeProtype: [],
      defaultCheckedKeys: [],
      cascaderValue: [],
      selectValue: [],
      productsList: [],
      campList: [],
      GoodsHotelList: [],
      titles: ["待选商品", "已选商品"],
      transferValue: [],
      transferProtype: [],
      treeProtyLIST: [],
      treeProtyLISTS: [],
      PLProtyLIST: [],
      couponStatus: true,
      zdPeoValue: [],
      zdPeoProductList: [],
      member_level: [],
      MerchantLIST: [],
      MerchantValue: [],
      formFields1: {
        bookingName: "",
        bookingPhone: "",
        bookingIdCard: "",
        teamScheduled: 0,
        bookingType: "",
        playStartDate: "",
        reservationType: 0,
        certificate_type: "",
        teamType: 0,
        reserveValue: "",
        spare14: "",
        reserveValueName: "",
        external_order_number1: ""
      },
      formRules1: [
        [
          {
            title: "手机号",
            field: "bookingPhone",
            type: "phone",
            required: true,
            colSize: 4,
            onKeyPress: $event => {
              if ($event.keyCode == 13) {
                this.searchInfo();
              }
            }
          },
          {
            render: (h, {}) => {
              return h(
                "button",
                {
                  class: "ivu-btn",
                  style: {
                    "margin-left": "10px"
                  },
                  on: {
                    click: () => {
                      this.searchInfo();
                    }
                  }
                },
                "查询"
              );
            },
            disabled: true,
            colSize: 1
          },
          {
            title: "姓名",
            field: "bookingName",
            type: "notnumbers",
            required: true,
            colSize: 5
          }
        ],
        [
          {
            title: "证件类型",
            field: "certificate_type",
            type: "select",
            dataKey: "certificate_type",
            data: [],
            colSize: 5
          },
          {
            title: "证件号",
            field: "bookingIdCard",
            type: "text",
            // disabled:true,
            colSize: 5
          }
        ],
        [
          {
            title: "团队预定",
            field: "teamScheduled",
            type: "switch",
            colSize: 5,
            onChange: (val, option) => {
              this.teamScheduledNum = val;
              let teamType = this.getOption("teamType");
              if (this.teamScheduledNum == 1) {
                teamType.hidden = false;
                teamType.required = true;
              } else {
                teamType.hidden = true;
                teamType.required = false;
              }
            }
          },
          {
            title: "团队分类",
            field: "teamType",
            type: "select",
            data: [
              { key: 0, value: "团进团出" },
              { key: 1, value: "团进散出" }
            ],
            hidden: true,
            required: false,
            colSize: 5
          }
        ],
        [
          {
            title: "预定类型",
            field: "reservationType",
            type: "select",
            dataKey: "reservationTypesimple",
            required: true,
            data: [],
            colSize: 5,
            onChange: (val, option) => {
              let reserveValue = this.getOption("reserveValue");
              if (val == 2 || val == 4) {
                reserveValue.hidden = true;
                reserveValue.required = false;
              } else {
                reserveValue.hidden = false;
                reserveValue.required = true;
              }
            }
          },
          {
            title: "挂账单位",
            field: "reserveValue",
            type: "select",
            data: [],
            required: false,
            hidden: true,
            colSize: 5
          },
          {
            title: "挂账单位",
            field: "reserveValueName",
            type: "text",
            required: false,
            hidden: true,
            colSize: 5
          }
        ],
        [
          {
            title: "第三方订单",
            field: "external_order_number1",
            type: "text",
            data: [],
            colSize: 5
          }
        ],
        [
          {
            title: "备注",
            field: "spare14",
            type: "textarea",
            data: [],
            colSize: 12
          }
        ]
      ],
      formFields2: {
        name: "",
        phone: "",
        certificate_type: "",
        id_card: "",
        distributorCode: "",
        nickname: ""
      },
      formFields12: {
        head_img: "",
        gender: "",
        height: "",
        // 姓名
        name: "",
        IdCard: "",
        IdCardType: "",
        shoeSize: "",
        parentsIdCard: "",
        parentsName: "",
        parentsPhone: "",
        plateNum: "",
        skiLevel: "",
        weight: "",
        remarks: "",
        modifier: "",
        modifyDate: "",
        modifyID: "",
        createDate: "",
        createID: "",
        creator: "",
        memberPhone: "",
        type: "",
        isUsable: 1
      },
      formRules12: [
        [
          {
            title: "监护人手机号",
            field: "parentsPhone",
            type: "phone",
            required: true,
            colSize: 4,
            onKeyPress: $event => {
              if ($event.keyCode == 13) {
                // this.searchUseinfo();
                this.campSearch();
              }
            }
          },
          {
            render: (h, {}) => {
              return h(
                "button",
                {
                  class: "ivu-btn",
                  style: {
                    "margin-left": "10px"
                  },
                  on: {
                    click: () => {
                      this.campSearch();
                    }
                  }
                },
                "查询"
              );
            },
            colSize: 1
          },
          {
            title: "姓名",
            field: "name",
            type: "notnumbers",
            required: true,
            colSize: 5
          }
        ],
        [
          {
            dataKey: "gender",
            data: [],
            title: "性别",
            field: "gender",
            type: "select"
          },
          {
            dataKey: "type",
            data: [
              {
                value: "儿童",
                key: 0
              },
              {
                value: "成人",
                key: 1
              }
            ],
            title: "类型",
            field: "type",
            type: "select"
          },
          { title: "身高", field: "height", type: "text" }
        ],
        [
          {
            dataKey: "certificate_type",
            data: [],
            title: "证件类型",
            field: "IdCardType",
            required: true,
            type: "select"
          },
          { title: "证件号", field: "IdCard", type: "text", required: true },
          {
            field: "plateNum",
            title: "单双板",
            type: "radio",
            width: 90,
            align: "left",
            dataKey: "plateNum",
            data: []
          }
        ],
        [
          { title: "鞋码", field: "shoeSize" },
          { title: "体重", field: "weight", type: "text" },
          { title: "滑雪水平", field: "skiLevel", type: "text" }
        ],

        [
          { title: "监护人姓名", field: "parentsName" },

          { title: "监护人证件号", field: "parentsIdCard" },
          {
            data: [
              {
                value: "可用",
                key: 1
              },
              {
                value: "不可用",
                key: 0
              }
            ],
            title: "状态",
            field: "isUsable",
            type: "select"
          }
        ],
        [
          {
            title: "注意事项/备注",
            field: "remarks",
            type: "textarea",
            colSize: 12
          }
        ]
      ],
      formRules2: [
        [
          {
            title: "手机号",
            field: "phone",
            type: "phone",
            required: true,
            colSize: 4,
            onKeyPress: $event => {
              if ($event.keyCode == 13) {
                this.searchUseinfo();
              }
            }
          },
          {
            render: (h, {}) => {
              return h(
                "button",
                {
                  class: "ivu-btn",
                  style: {
                    "margin-left": "10px"
                  },
                  on: {
                    click: () => {
                      this.searchUseinfo();
                    }
                  }
                },
                "查询"
              );
            },
            colSize: 1
          },
          {
            title: "姓名",
            field: "name",
            type: "notnumbers",
            required: true,
            colSize: 5
          }
        ],
        [
          {
            title: "证件类型",
            field: "certificate_type",
            type: "select",
            dataKey: "certificate_type",
            data: [],
            colSize: 5
          },
          {
            title: "证件号",
            field: "id_card",
            type: "text",
            colSize: 5
          }
        ]
      ],
      formFileds3: {
        date: "",
        distributorCode: ""
      },
      formFileds5: {
        distributorCode: ""
      },
      formRules3: [
        [
          {
            title: "分销商",
            field: "distributorCode",
            type: "select",
            required: true,
            data: [],
            onChange: val => {
              this.getly(val);
            }
          },
          {
            title: "使用日期",
            field: "date",
            type: "date",
            min: new Date().getTime() - 1000 * 60 * 60 * 24,
            required: true
          }
        ]
      ],
      flxjxzly: false,
      formly: { sourceid_distributor: "" },
      formRulesly: [
        [
          {
            title: "来源",
            field: "sourceid_distributor",
            type: "select",
            data: [],
            required: false,
            colSize: 5
          }
        ]
      ],
      formRules7: [
        [
          {
            title: "分销商",
            field: "distributorCode",
            type: "select",
            colSize: 5,
            required: true,
            data: []
          }
        ]
      ],
      formFileds4: {
        hotelid: "",
        roomcode: "",
        distributionid: "",
        date: "",
        stockNumebr: "1"
      },
      formRules4: [
        [
          {
            title: "分销商",
            field: "distributionid",
            type: "select",
            required: true,
            data: [],
            colSize: 6,
            onChange: val => {
              this.getly(val);
            }
          },
          {
            title: "酒店名称",
            field: "hotelid",
            type: "select",
            required: true,
            data: [],
            colSize: 6,
            onChange: (val, option) => {
              if (val != "" || val != null) {
                let roomcode = this.getOption4("roomcode");
                let param1 = {
                  page: 1,
                  rows: 1000,
                  sort: "id",
                  order: "desc",
                  wheres: "[]",
                  value: val
                };
                this.http
                  .post("/api/Hotels/getDetailPage", param1)
                  .then(res => {
                    this.roomList = [];
                    res.rows.forEach(item => {
                      let obj = {
                        value: item.room_Name || 0,
                        key: item.room_Code || 0
                      };
                      this.roomList.push(obj);
                      this.$set(roomcode, "data", this.roomList);
                    });
                  });
              } else {
                this.$Message.success("请先选择酒店");
              }
            }
          }
        ],
        [
          {
            title: "房型码",
            field: "roomcode",
            type: "select",
            required: true,
            data: [],
            colSize: 3
          },
          {
            title: "房间数量",
            field: "stockNumebr",
            type: "text",
            required: true,
            colSize: 3
          },

          {
            title: "起止时间",
            field: "date",
            type: "datetime",
            min: new Date().getTime() - 1000 * 60 * 60 * 24,
            required: true,
            range: true,
            colSize: 6
          }
        ]
      ],
      formFields6: {
        pmsconfirmationNo: ""
      },
      formRules6: [
        [
          {
            title: "PMS确认号",
            field: "pmsconfirmationNo",
            type: "text"
          }
        ]
      ],
      CouponMemberid: [
        {
          field: "couponid",
          title: "优惠券id",
          type: "string",
          width: 120,
          require: true,
          align: "left"
        },
        {
          field: "name",
          title: "券名称",
          type: "string",
          width: 120
        },
        {
          field: "product_id",
          title: "商品id",
          type: "string",
          width: 120
        },
        {
          field: "product_name",
          title: "商品名称",
          type: "string",
          width: 120
        },
        {
          field: "use_status",
          title: "使用状态",
          type: "int",
          bind: { key: "", data: [{ key: 1, value: "未使用" }] },
          width: 120
        },
        {
          field: "type",
          title: "券类型 ",
          type: "int",
          bind: { key: "Coupon_Type", data: [] },
          width: 120
        },
        {
          field: "use_type",
          title: "使用类型",
          bind: {
            key: "",
            data: [
              { key: 1, value: "通用" },
              { key: 2, value: "品类" },
              { key: 3, value: "商品" }
            ]
          },
          type: "int",
          width: 120
        },
        {
          field: "coupon_value",
          title: "优惠值",
          type: "string",
          width: 120
        },

        {
          field: "use_starttime",
          title: "使用开始时间",
          type: "string",
          width: 120
        },
        {
          field: "use_endtime",
          title: "使用结束时间",
          type: "string",
          width: 120
        }
      ],
      CouponMemberidData: []
    };
  }
};
</script>
<style>
.sysm > .el-form-item__content {
  width: 87% !important;
}
.edit_dev .el-transfer-panel {
  width: 280px !important;
}
.edit_dev .el-transfer__buttons {
  padding: 0 15px !important;
}
.edit_dev.el-button {
  padding: 10px 15px !important;
}
.lablecolor .el-form-item__label {
  color: #939394 !important;
  font-size: 12px !important;
}
</style>
<style lang="scss" scoped>
.hx {
  margin: 10px 0;
  border-bottom: 1px solid #ccc;
  padding-bottom: 10px;
}
.z {
  width: 50px;
}
.el-form-item {
  width: 47% !important;
}
.el-transfer {
  margin-top: 20px;
}
.treeS {
  height: 200px;
  overflow-y: scroll;
}
.cascader {
  margin-top: 20px;
  display: flex;
  .casd {
    max-height: 300px;
    overflow-y: auto;
    width: 2.8rem;
  }
  .el-transfer {
    margin-left: 20px;
    margin-top: 0;
  }
}
.sysm {
  width: 100% !important;
  display: flex;
}
.meInt {
  width: 92%;
}
.fr {
  float: right;
}
</style>
